package cn.ainit.sys.print;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.util.ArrayList;
import java.util.List;

public class Printclass implements Printable{
public Printclass(){
	
}
	@Override
	public int print(Graphics gra, PageFormat pf, int pageIndex)
	throws PrinterException {
		System.out.println("pageIndex="+pageIndex);
		Component c = null;
		//print string
		String str = "";
		//转换成Graphics2D
		Graphics2D g2 = (Graphics2D) gra;
		//设置打印颜色为黑色
		g2.setColor(Color.black);

		//打印起点坐标
		double x = pf.getImageableX();
		double y = pf.getImageableY();

		switch(pageIndex){
		case 0:
			float[]   dash1   =   {2.0f}; 
			//设置打印线的属性。
			//1.线宽 2、3、不知道，4、空白的宽度，5、虚线的宽度，6、偏移量
			g2.setStroke(new   BasicStroke(0.5f,   BasicStroke.CAP_BUTT,   BasicStroke.JOIN_MITER,   2.0f,   dash1,   0.0f));  
			return PAGE_EXISTS;
		default:
			return NO_SUCH_PAGE;
		}
	}
	
}
